import httpRequest from './httpRequest';

export default {
   httpPost: async (path = '', data = {}, flag = true) => {
    if (!path) {
      throw new Error('Request path is required');
    }

    const url = httpRequest.adornUrl(path);
    const requestData = httpRequest.adornData(data, flag);
    try {
      const response = await httpRequest.post(url, requestData);
      return response.data;
    } catch (error) {
      return error;
    }
   },
   httpGet: async (path, params = {}) => {
    const url = httpRequest.adornUrl(path);
    const requestParams = httpRequest.adornParams(params);
    try {
       const response = await httpRequest.get(url, { params: requestParams });
       return response.data;
     } catch (error) {
       return error;
     }
   }
};
